import 'package:flutter/material.dart';
import 'package:flutter_demo/chapter6-Roll/cache/KeepAliveWrapper.dart';

void main() {
  runApp(MaterialApp(
    home: TabBarViewWidget2(),
  ));
}

class TabBarViewWidget2 extends StatelessWidget {
  List tabs = ["新闻", "历史", "图片"];

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: tabs.length,
      child: Scaffold(
        appBar: AppBar(
          title: const Text('App Name'),
          bottom: TabBar(
            tabs: tabs.map((e) => Tab(text: e)).toList(),
          ),
        ),
        body: TabBarView(
          children: tabs.map((e) {
            return KeepAliveWrapper(
              child: Container(
                alignment: Alignment.center,
                child: Text(
                  e,
                  textScaleFactor: 5,
                ),
              ),
            );
          }).toList(),
        ),
      ),
    );
  }
}
